import axios from "@/utils/request.js";

/**
 * 添加标签
 * @param tagContent
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const tagAddService = (tagContent) => {
  return axios.post("/tagInfo/add",{tagContent})
}

/**
 * 分页查询所有标签
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const tagSelectService = (pageNo,pageSize,tagContentFuzzy) => {
  return axios.get("/tagInfo/loadDataList",{params:{
    pageNo,pageSize,tagContentFuzzy
  }})
}

/**
 * 删除标签
 * @param tagId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const tagDeleteService = (tagId) => {
  return axios.delete("/tagInfo/deleteTagInfoByTagId",{params:{
    tagId
  }} )
}

/**
 * 添加题目
 * @param titleForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const titleAddService = (titleForm) => {
  return axios.post("/titleInfo/add",titleForm)
}

/**
 * 分页查询题目信息
 * @param pageNo
 * @param pageSize
 * @param titleNameFuzzy
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const titlePageService = (pageNo,pageSize,titleNameFuzzy) => {
  return axios.get("/titleInfo/loadDataList",{params:{
    pageNo, pageSize, titleNameFuzzy
    }})
}

/**
 * 根据删除题目以及题目对应标签的关联关系
 * @param titleId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const titleDeleteService = (titleId) => {
  return axios.delete("/titleInfo/deleteTitleInfoByTitleId",{params:{
    titleId
  }})
}

/**
 * 根据标签id数组查询标签名字数组
 * @param selectIds
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const tagIdSelectNameService = (selectIds) => {
  return axios.post("/tag/selectNameByIds",selectIds)
}

/**
 * 修改题目
 * @param titleForm
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const titleModifyService = (titleForm) => {
  return axios.put("/titleInfo/updateTitleInfoByTitleId",titleForm)
}

/**
 * 查询所有题目
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const titleSelectAllService = () => {
  return axios.get("/title/selectAll")
}

/**
 * 查询所有题目数量（用于echarts图渲染）
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const titleCountAllService = () => {
  return axios.get("/title/countAll")
}
